package ru.evga.inse.server.gwt.admin.client.menu.dict.street;

import ru.evga.gwt.lib.common.client.actitvity.AbstractEntityListActivity;
import ru.evga.inse.server.gwt.admin.client.IAdminAppFactory;
import ru.evga.inse.server.gwt.common.client.domain.dict.StreetDto;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.user.client.Window;


public class StreetListActivity
    extends AbstractEntityListActivity<StreetDto>
{
    private final IAdminAppFactory factory;

    public StreetListActivity(IAdminAppFactory factory)
    {
        super(factory.getViewFactory().getStreetListView());
        this.factory = factory;
    }

    
    public void onEditClicked(StreetDto item)
    {
        StreetEditDialog dialog = new StreetEditDialog(item, this);
        dialog.setTitle("Edit Street");
        dialog.open();
    }

//    public void onRemoveClicked(final StreetDto item)
//    {
//        ConfirmDialog dialog = new ConfirmDialog("Delete street '"+ item.getName() +"'?", ConfirmDialog.BUTTON_TYPE.YES_NO, new ConfirmDialog.AbstractConfirmDialogHandler()
//        {
//            
//            public void onYes()
//            {
//                Window.alert("OnDeleted");
//
////                InstanceRequest<ru.xevgalex.infosea.client.managed.request.CityProxy, java.lang.Void> r = m_factory.getApplicationRequestFactory().cityRequest().remove();
////                r.using(item).fire(new Receiver<Void>()
////                {
////                    @Override
////                    public void onSuccess(Void response)
////                    {
////                    }
////                    @Override
////                    public void onFailure(ServerFailure error)
////                    {
////                        super.onFailure(error);
////                        Window.alert(error.getMessage());
////                    }
////                });
//            }
//        });
//        dialog.setTitle("Delete Street");
//        dialog.open();
//    }

    public void onShowDetails(StreetDto record)
    {
        Window.alert("OnShow");
//        Window.alert(record.toString());
    }
    
    public void onCreateClicked()
    {
        StreetEditDialog dialog = new StreetEditDialog(StreetDto.createEmptyStreetDto(), this);
        dialog.setTitle("New Street");
        dialog.open();
    }

    public void onSelected(StreetDto item)
    {
    }

    @Override
    protected String getEntityName()
    {
        return "street";
    }
    
    @Override
    protected JavaScriptObject getEntityRangeFilter()
    {
        return null;
    }

}

